<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>审批人</title>
<meta name="author" content="duanqixin@163.com" />
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/js/jquery-1.8.2.js"></script>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/resources/css/approval.css" />
<script type="text/javascript">
var flag = "1";//为0时，只能选择一个申请人

$(document).ready(function(){
	//审批人点击事件
	$("#hm_agree input").click(function() {
		//取消不同意
		$("#hm_unAge").attr("checked", false);
		var sup = $(this).parent().parent();
		if($(this).attr("checked")) {
			sup.find("input[name='step']").attr("checked", true);
		}else {
			if(sup.find("input:checked").length == 1) {
				sup.find("input[name='step']").attr("checked", false);
			}
		}
	});
	//不同意点击事件
	$("#hm_unAge").click(function() {
		if($(this).attr("checked")) {
			$("#hm_agree").find("input").attr("checked", false);
		}
	});
	
	//取消
	$("#app_canel").click(function() {
		parent.closeAppIfm();
	});
	//确定
	$("#app_sure").click(function() {
		var len = $("#hm_app_all").find("input:checked").length;
		if(len == 0) {
			alert("请选择下一办理人！");
			return;
		}
		
		//装配数据
		var o = {};
		if($("#hm_unAge").attr("checked")) {//不同意
			o.step = -1;
			o.approve = $("#hm_unAge").val();
		}else {
			var arr = $("#hm_agree").find("input[name='step']:checked");
			if(arr.length == 1) {
				o.step = $(arr[0]).val();
				var an = [];
				$(arr[0]).parent().find("input[name='app']:checked").each(function() {
					an.push($(this).val());
				});
				o.approve = an.join(",");
			}else {
				alert("错误操作,请关闭浏览器！");return;
			}
		}
		
		parent.submitData(o);
	});
});
</script>
</head>
<body style="margin: 0;padding: 0;">
	<div id="hm_app_all" style="height:430px; overflow:auto;">
		<c:if test="${nextApp != null}">
			<div style="background-color: #DC504A;line-height:25px;">不同意</div>
			<div>
				<div class="hm_ttr"><input id="hm_unAge" type="checkbox" value="${nextApp.approver}"/>${nextApp.approveName}</div>
			</div>
		</c:if>
		<div id="hm_agree">
			<div style="background-color: #56AC56;line-height:25px;">同意</div>
			<c:forEach items="${approver}" var="apps">
				<div style="line-height: 23px"><input type="checkbox" name="step" value="${apps.step}" disabled="disabled"/>${apps.name}
					<c:forEach items="${apps.approvers}" var="app">
						<div class="hm_ttr"><input type="checkbox" name="app" value="${app.userId}"/>${app.userName}</div>
					</c:forEach>
				</div>
			</c:forEach>
		</div>
	</div>
	<div style="line-height:30px; background-color:#bbb;">
		<button id="app_canel" class="appr_btn" style="margin: 0px 0px 0px 15px;">取消</button>
		<button id="app_sure" class="appr_btn" style="margin: 0px 0px 0px 236px;">确定</button>
	</div>
	<!-- <div id="hm_clothPanel">
		<div style="height:100%;background-color: #DDD;"></div>
		<div class="hm_load_img"></div>
	</div> -->
</body>
</html>